package com.mxchip.livestarmobile.mobile.db.dao

import androidx.lifecycle.LiveData
import androidx.room.*
import com.mxchip.livestarmobile.mobile.db.entity.Contact

@Dao
interface ContactDao {

//    @Query("SELECT * FROM Contact")
//    fun getAll(): LiveData<List<Contact>>

    @Query("SELECT * FROM Contact WHERE user_id = (:userId)")
    fun loadAllByUserId(userId: String): LiveData<List<Contact>>

    @Query("SELECT * FROM Contact WHERE uid IN (:ids)")
    fun loadAllByIds(ids: LongArray): LiveData<List<Contact>>

    @Query("SELECT * FROM Contact WHERE uid = (:id)")
    fun loadAllById(id: Long): LiveData<Contact>

    @Query("SELECT * FROM Contact WHERE first_name LIKE :first AND " + "last_name LIKE :last LIMIT 1")
    fun findByName(first: String, last: String): LiveData<Contact>

    @Insert
    suspend fun insertAll(vararg contacts: Contact)

    @Delete
    suspend fun delete(contact: Contact)

    @Update
    suspend fun update(vararg contacts: Contact)
}